<template>
  <a-dropdown :trigger="['click']" v-model="show">
    <div slot="overlay">
      <a-spin :spinning="loading">
        <a-tabs class="dropdown-tabs" :tabBarStyle="{textAlign: 'center'}" :style="{width: '297px'}">
          <a-tab-pane tab="提醒" key="1">
            <a-list class="tab-pane">
              <a-list-item v-for="(item,index) in remindInfo" :key="index">
                <a-list-item-meta :title="item.content+'待办事项通知'" description="崇明教育提醒您">
                  <a-avatar style="background-color: white" slot="avatar" src="https://img.tukuppt.com/ad_preview/00/52/31/abhGo5gSMl.jpg!/fw/260"/>
                </a-list-item-meta>
              </a-list-item>
            </a-list>
          </a-tab-pane>
        </a-tabs>
      </a-spin>
    </div>
    <span @click="fetchNotice" class="header-notice">
      <a-badge class="notice-badge" :count="remindCount">
        <a-icon :class="['header-notice-icon']" type="bell" />
      </a-badge>
    </span>
  </a-dropdown>
</template>

<script>
import HttpHome from "../../api/home";
export default {
  name: 'HeaderNotice',
  data () {
    return {
      loading: false,
      show: false,
      remindInfo:[],
      remindCount:0,
    }
  },
  computed: {
  },
  mounted(){
    this.getRemindInfo();
  },
  methods: {
    getRemindInfo(){
      HttpHome.getAllRemindInfo().then((res=>{
        if(res.data.code === 0){
          this.remindInfo=res.data.data
          this.remindCount=this.remindInfo.length;
        }
      }))
    },
    fetchNotice () {
      if (this.loading) {
        this.loading = false
        return
      }
      this.loadding = true
      setTimeout(() => {
        this.loadding = false
      }, 1000)
    }
  }
}
</script>

<style lang="less">
  .header-notice{
    display: inline-block;
    transition: all 0.3s;
    span {
      vertical-align: initial;
    }
    .notice-badge{
      color: inherit;
      .header-notice-icon{
        font-size: 16px;
        padding: 4px;
      }
    }
  }
  .dropdown-tabs{
    background-color: @base-bg-color;
    box-shadow: 0 2px 8px @shadow-color;
    border-radius: 4px;
    .tab-pane{
      padding: 0 24px 12px;
      min-height: 250px;
    }
  }
</style>
